require('player')
require('eventHandler')
require('world')
require('view')
require('shaders')
require('collectible')

--[[

	Game Functionality
	
--]]
--Win
function win()
	--You win!
end

--Loss
function lose()
	--You lost!
end


--[[
	
	LOVE Functionality
	
--]]
--Instantiate
function love.load()
	view:conf()
	world:initMap()

	world:load()
	player:load()
	glow:load()
	collider:load()
	--for loop that loads objects
    --randomize location of objects
end

--Redraw function
function love.draw()
	world:draw() --possibly unneeded depending on background
	player:draw()
	glow:draw()
	--draw all collectibles
	--draw all objects
  
	world:drawMap()
	--love.graphics.setPixelEffect(effect)
    --love.graphics.draw(effect, 400, 300, 0, 1, 1, 400, 300)
end

--Periodic update
function love.update(dt)
  --gather key input
	world:update()
	player:update()
	glow:update()
	collider:update()
	--check for collisions and notify
	--update all collectables
	--update all objects
	
	
	alive = player:setHealth(player.getHealth()-1)
	if alive == "false" then
		lose()
	end
	
	eventHandler:parseInput()
end